<template>
  <lesson v-for="lesson in lessons" :key="lesson.id" :lesson="lesson">
    <template #icon>:)</template>
    <template #del>
      <button @click="del(id)">删除</button>
    </template>
  </lesson>
</template>

<script>
import lessons from './data.js'
import Lesson from './Lesson.vue'
export default {
  components:{Lesson},
  data() {
    return {
      lessons
    }
  },
  methods: {
    del(id) {
      const index = this.lessons.findIndex(lessons => lessons.id == id)
      this.lessons.splice(index,1)
    }
  },
}
</script>

<style>

</style>